﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;
using InSimDotNet;
using InSimDotNet.Packets;
using InSimDotNet.Out;
using System.Collections;
using System.Text.RegularExpressions;
using System.Timers;
using System.Configuration;
/**
 * TOM-INSIM-LOGGER/PARSER
 * 
 * @author Perttu Katainen & Teemu Seppä
 * 
 * 
 * 
 * 
 * 
                                         RRRRRR  IIIII BBBBB     AAA   NN   NN  OOOOO  ZZZZZ              
                                         RR   RR  III  BB   B   AAAAA  NNN  NN OO   OO    ZZ              
                                         RRRRRR   III  BBBBBB  AA   AA NN N NN OO   OO   ZZ               
                                         RR  RR   III  BB   BB AAAAAAA NN  NNN OO   OO  ZZ                
                                         RR   RR IIIII BBBBBB  AA   AA NN   NN  OOOO0  ZZZZZ              
                                                                          
                                 SSSSS   OOOOO  FFFFFFF TTTTTTT WW      WW  OOOOO  RRRRRR  KK  KK  SSSSS  
                                SS      OO   OO FF        TTT   WW      WW OO   OO RR   RR KK KK  SS      
                                 SSSSS  OO   OO FFFF      TTT   WW   W  WW OO   OO RRRRRR  KKKK    SSSSS  
                                     SS OO   OO FF        TTT    WW WWW WW OO   OO RR  RR  KK KK       SS 
                                 SSSSS   OOOO0  FF        TTT     WW   WW   OOOO0  RR   RR KK  KK  SSSSS                                                     
        
 *  
 * */


namespace lfsserver6
{
   public class app
    {
        public static void Main(string[] args)
        {
            conf conf = new conf();
            GUI GUI = new GUI();
            parsers parsers = new parsers();

            conf.ConfigurationReader();
            int intPort;
            int.TryParse(conf.port, out intPort);
      

            GUI.test();

            using (InSim insim = new InSim())
            {


                //binds
                insim.Bind<IS_NCN>(parsers.player_join_data);
                insim.Bind<IS_NPL>(parsers.player_connection_data);
                insim.Bind<IS_MSO>(GUI.command);
                insim.Bind<IS_BTC>(GUI.deletebutton);


                insim.Initialize(new InSimSettings
                {


                    //initialize
                    Host = conf.ip,//this is example loopback. Use your server address instead.
                    Port = intPort,//insim port
                    Prefix = '!',
                    Admin = conf.password,
                    Interval = 3000,
                    Flags = InSimFlags.ISF_MCI,
                });
                Console.ReadLine();
            }
        }


    }
}
